<?php

namespace Portal\Controller;
use Common\Controller\HomebaseController; 
/**
 * 首页
 */
class IndexController extends HomebaseController {
	
 //首页
	public function index() {
    	$this->display(":index");
    	
    }
  
    /**
     * 成绩查询
     */
    public function query(){
    	$student = str_replace('请输入考生姓名', '', I('student'));
    	$number = str_replace('请输入准考证号/证件号', '', I('certificate'));//号码
    	$verify = str_replace('验证码', '', I("verify"));
    	
    	if($verify == ''){
    		$this->error('验证码不能为空！');
    	}
    	if($student == ''){
    		$this->error('考生姓名不能为空！');
    	}
    	if($number == ''){
    		$this->error('准考证号/证件号不能为空！');
    	}
    	if(!sp_check_verify_code()){
    		$this->error('验证码错误！');
    	}
    	$Score = M('Score');
    	
    	$where['idcard_num']  = $number;
    	$where['admission_num']  = $number;
    	$where['_logic'] = 'or';
    	$map['_complex'] = $where;
    	$map['student']  = $student;
    	
    	
    	$result = $Score->where($map)->find();
    	if(empty($result)){
    		$this->error('查询结果为空');
    	}
    	$this->assign('score',$result);
    	$this->display(':query');
    }
    /**
     * 成绩查询二维码版
     */
    public function queryQRcode() {
    	$student = str_replace('请输入考生姓名', '', I('student'));
    	$number = str_replace('请输入准考证号/证件号', '', I('certificate'));//号码
    	if($student == ''){
    		$this->error('考生姓名不能为空！');
    	}
    	if($number == ''){
    		$this->error('准考证号/证件号不能为空！');
    	}
    	$Score = M('Score');
    	
    	$where['certificate_num']  = $number;
    	$where['admission_num']  = $number;
    	$where['_logic'] = 'or';
    	$map['_complex'] = $where;
    	$map['student']  = $student;
    	 
    	 
    	$result = $Score->where($map)->find();
    	if(empty($result)){
    		$this->error('查询结果为空');
    	}
    	$this->assign('score',$result);
    	$this->display(':query');
    }

}


